package Auxiliary;

import java.util.Vector;

import javax.swing.JOptionPane;

import Store.State;


public class Sequence_State 
{
	private Vector<State> v;
	
	public Sequence_State()
	{
		this.v = new Vector<State>();
	}
	
	public void add(State s)
	{
		if(v.contains(s))
		{
			JOptionPane.showMessageDialog(null,
					"Elemento gia' presente", "Error",
					JOptionPane.WARNING_MESSAGE);
		}
		
		else
		{
			
			boolean trovato=false;
			int max=0;
			if(v!=null) max=v.size();
			for (int i=0; i<max && !trovato; i++)
			{
				if(v.elementAt(i).getName().compareToIgnoreCase(s.getName())>=0)
				{
					v.add(i, s);
					trovato=true;
				}
			}
			if(!trovato)
				v.add(s);
		}
		
	}
	
	public void delete(State s)
	{
		if(v.contains(s))
			v.remove(s);
		
		else
		{
			JOptionPane.showMessageDialog(null,
					"Elemento non presente", "Error",
					JOptionPane.WARNING_MESSAGE);
			
		}
	}
	
	public State get(int i)
	{
		return v.elementAt(i);
	}
	
	public Vector<State> getAll()
	{
		return v;
	}
	
	
	public int size() 
	{
		return v.size();
	}

	public void remove(int i) 
	{
		v.remove(i);	
	}

	public boolean isEmpty() 
	{
		return v.isEmpty();
	}

	
	
	
	
}